import request from '@/utils/request'
import { CHECC_API_CMS } from '@/constants/proxy'

export function getRoleList(params) {
  return request({
    url: CHECC_API_CMS + '/role/getList',
    method: 'post',
    data: {
      'roleName': '', 'roleType': '1',
      ...params,
    }
  })
}

export function getRoles(data) {
  return request({
    url: CHECC_API_CMS + '/role/getList',
    method: 'post',
    data
  })
}

// 根据主键删除角色
export function deleteRole(id) {
  return request({
    url: CHECC_API_CMS + '/role/' + id,
    method: 'delete'
  })
}

// 添加角色
export function addRole(data) {
  return request({
    url: CHECC_API_CMS + '/role',
    method: 'post',
    data: data
  })
}

/**
 * 更新角色
 * @param data
 */
export function updateRole(data) {
  return request({
    url: CHECC_API_CMS + '/role',
    method: 'put',
    data: data
  })
}

/**
 * 根据角色id查找菜单
 * @param id
 */
export function findRoleMenus(id) {
  return request({
    url: CHECC_API_CMS + '/role/findRoleMenus/' + id,
    method: 'get'
  })
}

// 获取全部权限数据
export function getJurisdictionList(parms,data) {
  return request({
    url: CHECC_API_CMS + '/sys-power/page',
    method: 'post',
    data,
    params: parms,
    
  })
}

// 获取选择权限数据
export function getPowers(roleId) {
  return request({
    url: CHECC_API_CMS + `/role/getPowers/${roleId}`,
    method: 'get',
  })
}